<template>
  <a-layout
    :style="{
      background: '#fff',
      padding: '20px',
    }"
  >
    页面跳转中..........
  </a-layout>
</template>

<script>
import tokenRefresh from "@/utils/token-refresh"

export default {
  data() {
    return {
      redirect: this.$route.query.redirect,
      token: this.$route.query.token,
      uuid: this.$route.query.uuid,
    }
  },
  mounted() {
    if (this.token == "") {
      this.$message.warning("参数传递错误")
      return
    }
    if (this.token) {
      this.$token.set(this.token, this.token)
      this.loginIn()
    }
    if (this.uuid) {
      this.$token.setUUID(this.uuid)
      this.loginBind()
    }
    // this.loginIn()
  },
  methods: {
    async loginIn() {
      const resultfresh = await tokenRefresh()
      if (resultfresh * 1 !== 200) {
        //刷新token到期
        this.$message.warning("链接已超时，请你重新登录")
        this.$token.clear()
        this.$router.to("/login")
        return
      }
      if (!this.redirect) this.redirect = "/home"
      this.$router.to(this.redirect)
      return
    },
    loginBind() {
      this.$router.to("/login/binding")
    },
  },
}
</script>

<style></style>
